//
//  RZVoicePlayer.h
//  RZIM
//
//  Created by reyzhang on 2021/8/23.
//  语音录制播放器

#import <Foundation/Foundation.h>
#import "RZIMDefine.h"
#import "RZMessageInfo.h"


NS_ASSUME_NONNULL_BEGIN

extern NSString *const kNotificationStopVoicePlayer;
extern NSString *const kNotificationContinuousPlay;
extern NSString *const kNotificationPlayVoice;


@protocol RZVoicePlayerObserver;

@interface RZVoicePlayer : NSObject

//播放状态
@property (nonatomic, readonly) BOOL isPlaying;

//消息id
@property (nonatomic, assign) long messageId;

//会话类型
@property (nonatomic, assign) RZConversationType conversationType;

//会话id
@property (nonatomic, copy) NSString *targetId;

+ (RZVoicePlayer *)defaultPlayer;

//- (BOOL)playVoice:(NSString *)messageId voiceData:(NSData *)data observer:(id<RCVoicePlayerObserver>)observer;
- (BOOL)playVoice:(RZConversationType)conversationType
         targetId:(NSString *)targetId
        messageId:(long)messageId
        direction:(RZMessageDirection)messageDirection
        voiceData:(NSData *)data
         observer:(id<RZVoicePlayerObserver>)observer;

- (void)stopPlayVoice;

- (void)resetPlayer;

@end


@protocol RZVoicePlayerObserver <NSObject>

- (void)PlayerDidFinishPlaying:(BOOL)isFinish;

- (void)audioPlayerDecodeErrorDidOccur:(NSError *)error;

@end

NS_ASSUME_NONNULL_END
